//
//  ViewController.m
//  tableview
//
//  Created by 宋 on 15/11/19.
//  Copyright © 2015年 宋. All rights reserved.
//

#import "ViewController.h"
#import "inputTableViewController.h"
//@interface ViewController ()<UITableViewDataSource,UITableViewDelegate>
@interface ViewController  ()<InputFinshDelegate>
{
    NSArray * name;
    NSArray * num;
    NSIndexPath * curIndexPath;
}

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"主题";
    name = @[@"汪晓",
             @"宋京科",
             @"付湘云",
             @"汪倩"
             ];
    num = @[@"15200411916",
            @"18076790102",
            @"15539581120",
            @"18085762633"
            ];
    /*self.tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain];
    //self.tableView.dataSource = self;
    //self.tableView.delegate = self;
    [self.view addSubview:self.tableView];*/
    
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return name.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:nil];
    cell.textLabel.text =name[indexPath.row];
    cell.detailTextLabel.text = num[indexPath.row];
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    /*cell.textLabel.text = @"灰太狼";
    cell.detailTextLabel.text = @"15200411916";
    cell.imageView.image = [UIImage imageNamed:@"灰太狼"];*/
    return cell;

}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    inputTableViewController *con = [[inputTableViewController alloc] initWithStyle:UITableViewStyleGrouped];
    //记录行数
    curIndexPath = indexPath;
    
    con.tel = num[indexPath.row];
    con.delegate = self;
    [self.navigationController pushViewController:con animated:YES];
}



- (void)inputFinshed:(NSString *)text
{
    NSMutableArray *arr = num.mutableCopy;
    [arr replaceObjectAtIndex:curIndexPath.row withObject:text];
    num = arr;
    [self.tableView reloadData];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
